package com.wocao.controller.uniapp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wocao.entity.ResponseResult;
import com.wocao.entity.ZyOwner;
import com.wocao.service.ZyOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * uni app owner控制器
 */
@CrossOrigin
@RestController
@RequestMapping("uni-app")
public class OwnerController {

    @Autowired
    private ZyOwnerService zyOwnerService;

    /**
     * 业主头像修改方法
     */
    @PutMapping("ownerAvatar")
    public ResponseResult update(@RequestBody ZyOwner owner) {
        //存入对应业主的头像
        ZyOwner oldOwner = zyOwnerService.getOne(new QueryWrapper<>(new ZyOwner()).eq("owner_phone_number", owner.getOwnerPhoneNumber()));
        oldOwner.setOwnerPortrait(owner.getOwnerPortrait());
        zyOwnerService.updateById(oldOwner);
        return ResponseResult.ok();
    }


}
